package cc.rengu.igas.share.facade.bean.cups;

import cc.rengu.oltp.service.common.enums.OltpRpcdEnum;
import cc.rengu.oltp.service.model.BizException;

import java.util.Arrays;

/**
 * F57 AS AR  附加应答信息取值
 *
 * @author fangminwei
 * @date 2021/4/17
 */
@SuppressWarnings("AlibabaEnumConstantsMustHaveComment")
public enum F57_AS_AR_RspCodeEnum implements CupsRspCodeEnum.Type {
    _00_00(F39_RspCodeEnum._00.getCode(), "00", "对于对于自助终端（F60.2.5=01、05）发起的转账，该取值在部分存量交易中表示延迟转账；为便于机构改造过渡，F104TT用法也表示转账时效信息。当F104TT和F57AS+AR同时存在时，以F104TT时效为准，具体提示参见6.57.16.2.3。"),
    _05_00(F39_RspCodeEnum._05.getCode(), "00", "缺省值，不细化应答场景"),
    _05_01(F39_RspCodeEnum._05.getCode(), "01", "网上交易的交易信息超期送达"),
    _05_02(F39_RspCodeEnum._05.getCode(), "02", "证件类型不符"),
    _05_03(F39_RspCodeEnum._05.getCode(), "03", "身份证号、手机号、姓名中有1项或多项不符"),
    _05_04(F39_RspCodeEnum._05.getCode(), "04", "交换中心判断安全信息与交易信息的时间差超过24小时"),
    _05_05(F39_RspCodeEnum._05.getCode(), "05", "持卡人出生日期校验不符"),
    _05_06(F39_RspCodeEnum._05.getCode(), "06", "助农取款业务中，受理方未上送卡片信息"),
    _05_07(F39_RspCodeEnum._05.getCode(), "07", "证件号码错误次数超限；"),
    _05_08(F39_RspCodeEnum._05.getCode(), "08", "动态码错误/动态码过期；"),
    _05_09(F39_RspCodeEnum._05.getCode(), "09", "动态码错误次数超限"),
    _05_10(F39_RspCodeEnum._05.getCode(), "10", "无卡交易CVN2校验失败；"),
    _05_11(F39_RspCodeEnum._05.getCode(), "11", "无卡交易CVN2错误次数超限；"),
    _05_12(F39_RspCodeEnum._05.getCode(), "12", "校验要素少于业务规则的最少要求/业务要求必送的要素没有上送"),
    _05_13(F39_RspCodeEnum._05.getCode(), "13", "汇款验证姓名比对失败"),
    _05_14(F39_RspCodeEnum._05.getCode(), "14", "汇款交易中证件类型不支持"),
    _05_15(F39_RspCodeEnum._05.getCode(), "15", "验证总次数超限"),
    _13_00(F39_RspCodeEnum._13.getCode(), "00", "缺省值，不细化应答场景"),
    _13_01(F39_RspCodeEnum._13.getCode(), "01", "理应出现有效金额的交易中，金额域填0或其它非法值；"),
    _13_02(F39_RspCodeEnum._13.getCode(), "02", "超转付金额累计/超现付金额累计；"),
    _13_03(F39_RspCodeEnum._13.getCode(), "03", "交易超消费比例；"),
    _13_04(F39_RspCodeEnum._13.getCode(), "04", "小费金额超限；"),
    _13_05(F39_RspCodeEnum._13.getCode(), "05", "此机构无法/不可进行该币种交易；"),
    _13_06(F39_RspCodeEnum._13.getCode(), "06", "退款金额超过原始金额；"),
    _13_07(F39_RspCodeEnum._13.getCode(), "07", "预授权结算金额超限；"),
    _13_08(F39_RspCodeEnum._13.getCode(), "08", "分期付款交易金额小于起付限额；"),
    _13_09(F39_RspCodeEnum._13.getCode(), "09", "分期付款金额小于每期最小金额；"),
    _13_10(F39_RspCodeEnum._13.getCode(), "10", "超出无卡交易金额限额"),
    _13_11(F39_RspCodeEnum._13.getCode(), "11", "超出跨境/跨地区交易金额限额"),
    _13_12(F39_RspCodeEnum._13.getCode(), "12", "面额不在范围内"),
    _13_13(F39_RspCodeEnum._13.getCode(), "13", "交易金额小于最低限额"),
    _13_14(F39_RspCodeEnum._13.getCode(), "14", "圈存金额低于最小限额"),
    _13_15(F39_RspCodeEnum._13.getCode(), "15", "圈存金额高于最高限额"),
    _13_16(F39_RspCodeEnum._13.getCode(), "16", "在外汇管制国家，超过当地监管结汇额度"),
    _13_17(F39_RspCodeEnum._13.getCode(), "17", "账户余额超限"),
    _14_00(F39_RspCodeEnum._14.getCode(), "00", "缺省值，不细化应答场景"),
    _14_01(F39_RspCodeEnum._14.getCode(), "01", "发卡方无此主账号（卡号）"),
    _14_02(F39_RspCodeEnum._14.getCode(), "02", "在找到原始交易的情况下，关联交易主账号与原始交易主账号不匹配"),
    _14_03(F39_RspCodeEnum._14.getCode(), "03", "卡号校验位校验不正确"),
    _14_04(F39_RspCodeEnum._14.getCode(), "04", "帐户已作废或消户"),
    _14_05(F39_RspCodeEnum._14.getCode(), "05", "应答交易主账号与请求交易的主账号不匹配"),
    _14_06(F39_RspCodeEnum._14.getCode(), "06", "账户种类不对；"),
    _14_07(F39_RspCodeEnum._14.getCode(), "07", "该卡号无对应账户"),
    _14_08(F39_RspCodeEnum._14.getCode(), "08", "电子现金账户不存在/未开通"),
    _14_09(F39_RspCodeEnum._14.getCode(), "09", "账户已销户"),
    _14_10(F39_RspCodeEnum._14.getCode(), "10", "账户已作废"),
    _14_11(F39_RspCodeEnum._14.getCode(), "11", "银行资金账号不存在"),
    _14_12(F39_RspCodeEnum._14.getCode(), "12", "保留使用，具体参见《单位支付标记业务账户机构技术实施指南》"),
    _14_13(F39_RspCodeEnum._14.getCode(), "13", "保留使用，具体参见《单位支付标记业务账户机构技术实施指南》"),
    _14_14(F39_RspCodeEnum._14.getCode(), "14", "保留使用，具体参见《单位支付标记业务账户机构技术实施指南》"),
    _21_00(F39_RspCodeEnum._21.getCode(), "00", "缺省值，不细化应答场景"),
    _21_01(F39_RspCodeEnum._21.getCode(), "01", "该卡未激活、开卡；"),
    _21_02(F39_RspCodeEnum._21.getCode(), "02", "该卡初始密码未变更；"),
    _21_03(F39_RspCodeEnum._21.getCode(), "03", "初始密码限制的交易；"),
    _21_04(F39_RspCodeEnum._21.getCode(), "04", "长期未使用而冻结或状态为“睡眠”的卡"),
    _21_05(F39_RspCodeEnum._21.getCode(), "05", "处于换卡状态，密码还未激活"),
    _21_06(F39_RspCodeEnum._21.getCode(), "06", "暂停非柜面交易"),
    _22_00(F39_RspCodeEnum._22.getCode(), "00", "缺省值，不细化应答场景"),
    _22_01(F39_RspCodeEnum._22.getCode(), "01", "执行完冲正交易之后，又收到其撤销请求交易"),
    _22_02(F39_RspCodeEnum._22.getCode(), "02", "当前交易已被撤销，又收到其关联交易，例如冲正、撤销等"),
    _22_03(F39_RspCodeEnum._22.getCode(), "03", "执行完预授权撤销交易之后，又收到预授权完成交易"),
    _22_04(F39_RspCodeEnum._22.getCode(), "04", "执行完预授权冲正交易之后，又收到预授权完成交易"),
    _22_05(F39_RspCodeEnum._22.getCode(), "05", "当执行完预授权完成易后，又收到对同一笔预授权交易的预授权完成请求"),
    _22_06(F39_RspCodeEnum._22.getCode(), "06", "预授权类交易（包括预授权完成和预授权撤销）的发生时间超过允许的预授权类交易天数"),
    _22_07(F39_RspCodeEnum._22.getCode(), "07", "汇款交易中，汇款验证后，已发起了对应的联机的汇款交易（无论交易成功与否），又收到与汇款验证关联的联机汇款。"),
    _22_08(F39_RspCodeEnum._22.getCode(), "08", "超出正常缴费时间"),
    _30_00(F39_RspCodeEnum._30.getCode(), "00", "缺省值，不细化应答场景"),
    _30_01(F39_RspCodeEnum._30.getCode(), "01", "规定应出现的报文域未在报文中出现"),
    _30_02(F39_RspCodeEnum._30.getCode(), "02", "交易渠道取值不在规范定义中"),
    _30_03(F39_RspCodeEnum._30.getCode(), "03", "域解析出错"),
    _30_04(F39_RspCodeEnum._30.getCode(), "04", "子域解析出错"),
    _30_05(F39_RspCodeEnum._30.getCode(), "05", "域检查未通过"),
    _30_06(F39_RspCodeEnum._30.getCode(), "06", "域中出现非法字符"),
    _30_07(F39_RspCodeEnum._30.getCode(), "07", "接收报文中的bitmap不符合规范的定义"),
    _30_08(F39_RspCodeEnum._30.getCode(), "08", "磁道信息出错"),
    _30_09(F39_RspCodeEnum._30.getCode(), "09", "理应出现交易金额的交易中没有交易金额"),
    _30_10(F39_RspCodeEnum._30.getCode(), "10", "多用法域中，同一用法多次出现"),
    _40_00(F39_RspCodeEnum._40.getCode(), "00", "缺省值，不细化应答场景"),
    _40_01(F39_RspCodeEnum._40.getCode(), "01", "发卡方机构尚未开通此交易或不具备此交易权限"),
    _40_02(F39_RspCodeEnum._40.getCode(), "02", "受理方机构尚未开通此交易或不具备此交易权限"),
    _40_03(F39_RspCodeEnum._40.getCode(), "03", "卡bin权限尚未开通此交易"),
    _40_04(F39_RspCodeEnum._40.getCode(), "04", "发卡方无法进行某些验证要素的校验/超出发卡方校验范围"),
    _40_05(F39_RspCodeEnum._40.getCode(), "05", "该交易不支持跨地区/跨境使用"),
    _40_06(F39_RspCodeEnum._40.getCode(), "06", "该卡因监管原因，不开通相应功能"),
    _40_07(F39_RspCodeEnum._40.getCode(), "07", "未向交易发起方开通此交易权限"),
    _51_00(F39_RspCodeEnum._51.getCode(), "00", "缺省值，不细化应答场景"),
    _51_01(F39_RspCodeEnum._51.getCode(), "01", "账户可用余额不足/信用额度不足/取现额度超限"),
    _51_02(F39_RspCodeEnum._51.getCode(), "02", "预授权后账户余额小于0"),
    _51_03(F39_RspCodeEnum._51.getCode(), "03", "跨行取现余额足，但不足支付手续费，导致总余额不足"),
    _57_00(F39_RspCodeEnum._57.getCode(), "00", "缺省值，不细化应答场景"),
    _57_01(F39_RspCodeEnum._57.getCode(), "01", "该卡种不能做此种交易"),
    _57_02(F39_RspCodeEnum._57.getCode(), "02", "不受理该种卡"),
    _57_03(F39_RspCodeEnum._57.getCode(), "03", "该帐户没有该币种"),
    _57_04(F39_RspCodeEnum._57.getCode(), "04", "此卡有套现嫌疑"),
    _57_05(F39_RspCodeEnum._57.getCode(), "05", "卡号或证件号在黑名单中"),
    _57_06(F39_RspCodeEnum._57.getCode(), "06", "客户状态进入黑名单"),
    _57_07(F39_RspCodeEnum._57.getCode(), "07", "该用户未进行业务签约/业务未开通"),
    _57_08(F39_RspCodeEnum._57.getCode(), "08", "该用户业务签约已过期/取消"),
    _57_09(F39_RspCodeEnum._57.getCode(), "09", "上送的无卡交易类型非法"),
    _57_10(F39_RspCodeEnum._57.getCode(), "10", "该卡不能跨地区/跨境使用"),
    _57_11(F39_RspCodeEnum._57.getCode(), "11", "该账户已被冻结"),
    _57_12(F39_RspCodeEnum._57.getCode(), "12", "汇款方命中黑名单，比如汇款国家、地区被制裁，汇款人涉及反洗钱、反恐怖融资等"),
    _57_13(F39_RspCodeEnum._57.getCode(), "13", "收款方命中黑名单，比如收款国家、地区被制裁，收款人涉及反洗钱、反恐怖融资等"),
    _57_14(F39_RspCodeEnum._57.getCode(), "14", "持卡人自主关闭该业务"),
    _57_15(F39_RspCodeEnum._57.getCode(), "15", "该卡存在欺诈风险"),
    _57_16(F39_RspCodeEnum._57.getCode(), "16", "扣款次数超限"),
    _57_17(F39_RspCodeEnum._57.getCode(), "17", "证件有效期过期"),
    _59_00(F39_RspCodeEnum._59.getCode(), "00", "缺省值，不细化应答场景"),
    _59_01(F39_RspCodeEnum._59.getCode(), "01", "CVN验证失败"),
    _59_02(F39_RspCodeEnum._59.getCode(), "02", "ARQC校验错"),
    _59_03(F39_RspCodeEnum._59.getCode(), "03", "磁道信息错误"),
    _61_00(F39_RspCodeEnum._61.getCode(), "00", "缺省值，不细化应答场景"),
    _61_01(F39_RspCodeEnum._61.getCode(), "01", "超单笔消费限额/超ATM单笔取现限额"),
    _61_02(F39_RspCodeEnum._61.getCode(), "02", "ATM日取现/POS日消费金额超限"),
    _61_03(F39_RspCodeEnum._61.getCode(), "03", "超持卡人自定义交易金额"),
    _61_04(F39_RspCodeEnum._61.getCode(), "04", "超转帐限额"),
    _61_05(F39_RspCodeEnum._61.getCode(), "05", "交易总额超出月限额、年限额"),
    _61_06(F39_RspCodeEnum._61.getCode(), "06", "超出境外取现/消费额度"),
    _61_07(F39_RspCodeEnum._61.getCode(), "07", "跨境汇款超单笔限额"),
    _61_08(F39_RspCodeEnum._61.getCode(), "08", "跨境汇款超日限额"),
    _61_09(F39_RspCodeEnum._61.getCode(), "09", "设备验证单日累计限额超限"),
    _61_10(F39_RspCodeEnum._61.getCode(), "10", "设备验证单笔限额超限"),
    _61_11(F39_RspCodeEnum._61.getCode(), "11", "Ⅱ、Ⅲ类户日累计交易金额超限"),
    _61_12(F39_RspCodeEnum._61.getCode(), "12", "Ⅱ、Ⅲ类户年累计交易金额超限"),
    _61_13(F39_RspCodeEnum._61.getCode(), "13", "贷记单账号入账日累计金额超限"),
    _61_14(F39_RspCodeEnum._61.getCode(), "14", "贷记商户额度管控超限"),
    _61_15(F39_RspCodeEnum._61.getCode(), "15", "贷记业务场景额度管控超限"),
    _92_00(F39_RspCodeEnum._92.getCode(), "00", "缺省值，不细化应答场景"),
    _92_01(F39_RspCodeEnum._92.getCode(), "01", "没有可用线路"),
    _92_02(F39_RspCodeEnum._92.getCode(), "02", "银联处理中心或入网机构的IP地址格式及端口号错误"),
    _92_03(F39_RspCodeEnum._92.getCode(), "03", "汇往中国的汇款交易中，国家外汇管理个人结售汇系统（SAFESystem）不在服务时间（建议在下一个服务时间内再试）"),
    _92_04(F39_RspCodeEnum._92.getCode(), "04", "汇往中国的汇款交易中，国家外汇管理个人结售汇系统（SAFESystem）暂时不能服务（建议10分种后重试）"),
    _92_05(F39_RspCodeEnum._92.getCode(), "05", "汇往中国的汇款交易中，国家外汇管理个人结售汇系统（SAFESystem）系统超时"),
    ;

    private String codeF39;
    private String code;
    private String desc;

    F57_AS_AR_RspCodeEnum(String codeF39, String code, String desc) {
        this.codeF39 = codeF39;
        this.code = code;
        this.desc = desc;
    }

    public String getCodeF39() {
        return codeF39;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }


    @Override
    public String toString() {
        return codeF39 + "_" + code + "-" + desc;
    }


    public static F57_AS_AR_RspCodeEnum find(String code) {
        F57_AS_AR_RspCodeEnum result = Arrays.stream(F57_AS_AR_RspCodeEnum.values())
                .filter(e -> e.getCode().equals(code)).findFirst().orElse(null);

        if (result == null) {
            throw new BizException(OltpRpcdEnum.PARAM_IS_EMPTY_OR_NULL.getRespCode(), "找不到对应的枚举信息" + code);
        }
        return result;
    }


    public static F57_AS_AR_RspCodeEnum getResult(String f39_RspCode, String f57_AS_AR_RspCode) {
        F57_AS_AR_RspCodeEnum result = Arrays.stream(F57_AS_AR_RspCodeEnum.values())
                .filter(e -> e.codeF39.equals(f39_RspCode) && e.code.equals(f57_AS_AR_RspCode)).findFirst().orElse(null);

        if (result == null) {
            throw new BizException(OltpRpcdEnum.PARAM_IS_EMPTY_OR_NULL.getRespCode(), "找不到对应的枚举信息" + "_" + f39_RspCode + "_" + f57_AS_AR_RspCode);
        }
        return result;
    }

    public static String getRspMsg(String f39_RspCode, String f57_AS_AR_RspCode) {
        return getResult(f39_RspCode, f57_AS_AR_RspCode).toString();
    }
}
